package com.playball.lottery.frm.buyhall;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.playball.lottery.R;
import com.playball.lottery.ApplicationData;
import com.playball.lottery.base.BaseActivity;
import com.playball.lottery.customview.ChildDTO;
import com.playball.lottery.customview.DelButtonAdapter;
import com.playball.lottery.customview.DelButtonAdapterBDSXDS;
import com.playball.lottery.customview.DelButtonAdapterBDZJQ;
import com.playball.lottery.customview.MyDialog;
import com.playball.lottery.customview.ShowTipDialog;
import com.playball.lottery.frm.yhzx.BetProtocolActivity;
import com.playball.lottery.frm.yhzx.JddRechargeListActivity;
import com.playball.lottery.nt.GetRequestParams;
import com.playball.lottery.util.Constants;
import com.playball.lottery.util.ConvertJsonToList;
import com.playball.lottery.util.DefConstants;
import com.playball.lottery.util.JCUtil;
import com.playball.lottery.util.JCxhlbSortList;
import com.playball.lottery.util.JczqBQCUtil;
import com.playball.lottery.util.LotConstants;
import com.playball.lottery.util.MyPreference;


/**
 * 北单购彩选号列表界面
 * 
 * @author zhoujun
 * 
 */
public class BDxhlbActivity extends BaseActivity implements DefConstants {
	/** 上下文内容 */
	private Context context;
	private TextView moneyText;
	private TextView tipText;
	private EditText et_beishu;
	private TextView btnBuy;
	private Button btnChioce;
	private View btnDelAll;
	/** 发起合买 */
	TextView buy_jcbasxhlb_btn_hemai;
	View buy_jczqxhlb_linearlayout01;
	View buy_jczqxhlb_linearlayout02;
	private String issueID;
	private String issueName;
	private int bs;// 倍数
	private long allMoney;// 总金额
	private long count; // 注数
	private String passType;
	private int buy_icon;
	private int len; // 全局变量长度
	private int currLen;// 未删除的剩余条数
	private String Activity;

	private ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();

	boolean[] selected = new boolean[] { false, false, false, false, false, false, false, false, false, false, false,
			false, false, false, false };
	// /** 北单比分过关方式 */
	// boolean[] bfselected = new boolean[] { false, false, false, false };
	/** 奖金预测 */
	private TextView tvMyuce;
	/** 最小奖金预测 */
	static BigDecimal bdminM = new BigDecimal("0");
	/** 最大奖金预测 */
	static BigDecimal bdmaxM = new BigDecimal("0");
	/** 北单玩法 */
	private String strBDWF = "";
	/** 北单玩法数字ID */
	private int playTypeID;

	LinearLayout foot_layout;
	TextView tv_bet_protocol;
	CheckBox cb_bet_protocol;
	ListView listView;

	private String[] dyn;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.context = this;
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.buy_bdxhlb);
		getWindow().setSoftInputMode(
				WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
						| WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

		// 获得传来的数组，并放入ListView
		Intent intent = getIntent();
		issueID = intent.getStringExtra("IssueID");
		strBDWF = intent.getStringExtra("strBDWF");
		issueName = intent.getStringExtra("IssueName");

		// 判断是竞彩足球还是北单
		Activity = intent.getStringExtra("Activity");

		ArrayList<ChildDTO> arrayList = (ArrayList<ChildDTO>) intent.getSerializableExtra("list_jcdto");
		len = arrayList.size();
		// 处理intent获取的数据
		if (strBDWF.equals("RQSPF") || (strBDWF.equals("SXDS"))) {
			for (ChildDTO child : arrayList) {
				String jc_mid = child.getmId();
				String str_hteam = child.gethTeam();
				String str_vteam = child.getvTeam();
				String str_sp = child.getStr_sp();
				String str_eq = child.geteQ();
				list = getData(jc_mid, str_hteam, str_vteam, str_sp, child.geteTime(), str_eq);
			}
		} else {
			for (ChildDTO child : arrayList) {
				String jc_mid = child.getmId();
				String str_hteam = child.gethTeam();
				String str_vteam = child.getvTeam();
				String str_content = "";
				List<String> selspslist = new ArrayList<String>();
				if (strBDWF.equals("BQC")) {
					str_content = child.getBtnBQCcontent();
					selspslist = child.getList_bqcgridview_selectsp();
				} else if (strBDWF.equals("ZJQ")) {
					str_content = child.getSelectZJQCG();
					selspslist = child.getList_zjqgridview_selectsp();
				} else if (strBDWF.equals("BF")) {
					// 转化list为string
					String str1;
					StringBuffer sb = new StringBuffer();
					for (int i = 0; i < child.getList_bfsgridview_selectconcent().size(); i++) {
						sb.append(child.getList_bfsgridview_selectconcent().get(i) + ","); // ,
					}
					for (int i = 0; i < child.getList_bfpgridview_selectconcent().size(); i++) {
						sb.append(child.getList_bfpgridview_selectconcent().get(i) + ","); // ,
					}
					for (int i = 0; i < child.getList_bffgridview_selectconcent().size(); i++) {
						sb.append(child.getList_bffgridview_selectconcent().get(i) + ","); // ,
					}
					str1 = sb.toString();
					str_content = str1;
					// SP值list合并
					List<String> selBFspslist = new ArrayList<String>();
					selBFspslist = child.getList_bfsgridview_selectsp();
					List<String> selBFspplist = new ArrayList<String>();
					selBFspplist = child.getList_bfpgridview_selectsp();
					List<String> selBFspflist = new ArrayList<String>();
					selBFspflist = child.getList_bffgridview_selectsp();
					selspslist = new ArrayList<String>(selBFspslist);
					selspslist.addAll(selBFspplist);
					selspslist.addAll(selBFspflist);
				}
				list = getBQCData(jc_mid, str_hteam, str_vteam, str_content, selspslist, child.geteTime());
			}
		}
		// 初始化按钮
		initView();
		listView = (ListView) findViewById(R.id.lv_select_match);

		LayoutInflater inflater = LayoutInflater.from(this);
		foot_layout = (LinearLayout) inflater.inflate(R.layout.bet_protocol_foot, null);
		tv_bet_protocol = (TextView) foot_layout.findViewById(R.id.bet_protocols);
		foot_layout.setGravity(Gravity.CENTER);
		cb_bet_protocol = (CheckBox) foot_layout.findViewById(R.id.bet_protocol_choice);
//		tv_bet_protocol.setText(Html.fromHtml("<u>我已阅读并同意《代购合买协议》"));
		tv_bet_protocol.setVisibility(View.VISIBLE);//显示代购合买协议
		cb_bet_protocol.setChecked(true);
		tv_bet_protocol.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivityForResult(new Intent(BDxhlbActivity.this, BetProtocolActivity.class), 0);
			}
		});
		listView.removeFooterView(foot_layout);
		listView.addFooterView(foot_layout);

		// //对选择的赛事进行排序,jc_mid
		ArrayList<HashMap<String, Object>> newlist = new ArrayList<HashMap<String, Object>>();
		newlist = JCxhlbSortList.SortListData(list);

		initBaseAdapter(newlist);

		/************************ 2014年6月17日15:56:27 ************************/
		int length;
		length = ApplicationData.getInstance().getList_jcdto().size();

		if (length > 15) {
			length = 15;
		}
		// 如果是比分，最多只有3串1
		if (strBDWF.equals("BF")) {
			if (length > 2) {
				length = 3;
			}

			if (length == 1) {
				selected[0] = true;
			} else if (length == 2) {
				selected[1] = true;
			} else if (length == 3) {
				selected[2] = true;
			} else {
				selected[2] = true;
			}

		} else
		// 如果是总进球 半全场 上下单双，最多只有6串1
		if (strBDWF.equals("ZJQ") || strBDWF.equals("BQC") || strBDWF.equals("SXDS")) {
			if (length > 5) {
				length = 6;
			}

			if (length == 1) {
				selected[0] = true;
			} else if (length == 2) {
				selected[1] = true;
			} else if (length == 3) {
				selected[2] = true;
			} else if (length == 4) {
				selected[3] = true;
			} else if (length == 5) {
				selected[4] = true;
			} else if (length == 6) {
				selected[5] = true;
			} 
			else {
				selected[5] = true;
			}

		} else {
			if (length == 1) {
				selected[0] = true;
			} else if (length == 2) {
				selected[1] = true;
			} else if (length == 3) {
				selected[2] = true;
			} else if (length == 4) {
				selected[3] = true;
			} else if (length == 5) {
				selected[4] = true;
			} else if (length == 6) {
				selected[5] = true;
			} else if (length == 7) {
				selected[6] = true;
			} else if (length == 8) {
				selected[7] = true;
			} else if (length == 9) {
				selected[8] = true;
			} else if (length == 10) {
				selected[9] = true;
			} else if (length == 11) {
				selected[10] = true;
			} else if (length == 12) {
				selected[11] = true;
			} else if (length == 13) {
				selected[12] = true;
			} else if (length == 14) {
				selected[13] = true;
			} else {
				selected[13] = true;
			}
		}

		String selectedStr = "";
		for (int i = 0; i < selected.length; i++) {
			if (selected[i] == true) {
				if (selectedStr.equals("")) {
					selectedStr = getResources().getStringArray(R.array.buy_jc_all)[i];
				} else {
					selectedStr = selectedStr + "," + getResources().getStringArray(R.array.buy_jc_all)[i];
				}
			}
		}
		passType = selectedStr.replace("串", "*");
		btnChioce.setText(selectedStr);
		allMoney = getMoney(ApplicationData.getInstance().getList_jcdto());

		View.OnClickListener listener = new View.OnClickListener() {
			@Override
			public void onClick(View view) {

				passType = "";
				Dialog dialog = null;
				String arrs[] = getResources().getStringArray(R.array.buy_jc_all);
				int length;
				length = ApplicationData.getInstance().getList_jcdto().size();

				if (length > 15) {
					length = 15;
				}
				// 如果是比分，最多只有3串1
				if (strBDWF.equals("BF")) {
					if (length > 2) {
						length = 3;
					}
				}
				// 如果是总进球 半全场 上下单双，最多只有6串1
				if (strBDWF.equals("ZJQ") || strBDWF.equals("BQC") || strBDWF.equals("SXDS")) {
					if (length > 5) {
						length = 6;
					}
				}

				if (length < 1) {
					Toast.makeText(BDxhlbActivity.this, R.string.bdxhlbactivity_1, Toast.LENGTH_SHORT).show();
				} else {
					String pass[] = new String[length];
					for (int i = 0; i < length; i++) {
						pass[i] = arrs[i];
					}
					Builder builder = new AlertDialog.Builder(BDxhlbActivity.this);
					builder.setCancelable(false);
					builder.setTitle(getString(R.string.buy_jclist_passtype));
					DialogInterface.OnMultiChoiceClickListener mutiListener = new DialogInterface.OnMultiChoiceClickListener() {

						@Override
						public void onClick(DialogInterface dialogInterface, int which, boolean isChecked) {
							selected[which] = isChecked;
						}
					};
					builder.setMultiChoiceItems(pass, selected, mutiListener);
					DialogInterface.OnClickListener btnListener = new DialogInterface.OnClickListener() {
						@Override
						public void onClick(DialogInterface dialogInterface, int which) {
							String selectedStr = "";
							for (int i = 0; i < selected.length; i++) {
								if (selected[i] == true) {
									if (selectedStr.equals("")) {
										selectedStr = getResources().getStringArray(R.array.buy_jc_all)[i];
									} else {
										selectedStr = selectedStr + ","
												+ getResources().getStringArray(R.array.buy_jc_all)[i];
									}
								}
							}
							passType = selectedStr.replace("串", "*");
							btnChioce.setText(selectedStr);
							allMoney = getMoney(ApplicationData.getInstance().getList_jcdto());
						}
					};
					builder.setPositiveButton("确定", btnListener);
					dialog = builder.create();
					dialog.show();
				}

			}
		};
		btnChioce.setOnClickListener(listener);

		// 购买按钮
		btnBuy.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {

				// TODO Auto-generated method stub
				if (list.size() < 1) {
					Toast.makeText(BDxhlbActivity.this, R.string.bdxhlbactivity_2, Toast.LENGTH_SHORT).show();
				} else if (passType == null || passType.equals("")) {
					Toast.makeText(BDxhlbActivity.this, R.string.bdxhlbactivity_3, Toast.LENGTH_SHORT).show();
				} else if (et_beishu.getText().toString().equals("")
						|| Long.parseLong(et_beishu.getText().toString()) == 0) {
					Toast.makeText(BDxhlbActivity.this, R.string.bdxhlbactivity_4, Toast.LENGTH_SHORT).show();
					et_beishu.setText("1");
				} else {

					if (cb_bet_protocol.isChecked() == false) {
						Toast.makeText(BDxhlbActivity.this, R.string.bdxhlbactivity_5, Toast.LENGTH_SHORT).show();
						return;
					}

					startBuyThread();

					/*
					 * MyDialog dialog = new MyDialog.Builder(
					 * BDxhlbActivity.this) .setTitle("购买提示")
					 * .setMessage("是否确认购买？") .setPositiveButton("确定", new
					 * DialogInterface.OnClickListener() { public void onClick(
					 * DialogInterface dialog, int which) { //
					 * startVouchersThread(); startBuyThread(); dialog.cancel();
					 * } }) .setNegativeButton("取消", new
					 * DialogInterface.OnClickListener() {
					 * 
					 * @Override public void onClick( DialogInterface dialog,
					 * int which) { dialog.cancel(); } }).create();
					 * dialog.setCanceledOnTouchOutside(false);
					 * dialog.setCancelable(true);// 设置back键是否可以取消
					 * dialog.show();
					 */
				}
			}
		});

		btnDelAll.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (ApplicationData.getInstance().getList_jcdto().size() > 0) {
					MyDialog.Builder dialog = new MyDialog.Builder(BDxhlbActivity.this);
					dialog.setTitle("清空号码提示");
					dialog.setMessage("清空后您已选择的号码列表将会清空，确认继续?");
					dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int which) {
							et_beishu.setText("1");
							moneyText.setText("共：0元");
							tvMyuce.setText("0");
							allMoney = 0;
							bs = 1;
							// 获得自定义的应用程序BallDTO,初始化
							ApplicationData.getInstance().resetJCData();
							list = new ArrayList<HashMap<String, Object>>();
							buy_jczqxhlb_linearlayout01.setVisibility(View.GONE);
							buy_jczqxhlb_linearlayout02.setVisibility(View.VISIBLE);
							tipText.setText("共--场比赛，截止时间：------------");
							currLen = 0;
							// 当用户选择清空时，初始化奖金预测值
							bdminM = new BigDecimal("0");
							bdmaxM = new BigDecimal("0");
							dialog.cancel();
						}
					});
					dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int which) {
							dialog.cancel();
						}
					}).create().show();
				}
			}
		});

		// 发起合买
		buy_jcbasxhlb_btn_hemai.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {

				if (list.size() < 1) {
					Toast.makeText(BDxhlbActivity.this, R.string.bdxhlbactivity_6, Toast.LENGTH_SHORT).show();
				} else if (passType == null || passType.equals("")) {
					Toast.makeText(BDxhlbActivity.this, R.string.bdxhlbactivity_7, Toast.LENGTH_SHORT).show();
				} else if (et_beishu.getText().toString().equals("")
						|| Long.parseLong(et_beishu.getText().toString()) == 0) {
					Toast.makeText(BDxhlbActivity.this, R.string.bdxhlbactivity_8, Toast.LENGTH_SHORT).show();
					et_beishu.setText("1");
				} else {
					if (strBDWF.equals("RQSPF")) {
						playTypeID = 4501;
					} else if (strBDWF.equals("ZJQ")) {
						playTypeID = 4502;
					} else if (strBDWF.equals("SXDS")) {
						playTypeID = 4503;
					} else if (strBDWF.equals("BF")) {
						playTypeID = 4504;
					} else if (strBDWF.equals("BQC")) {
						playTypeID = 4505;
					}

					if (cb_bet_protocol.isChecked() == false) {
						Toast.makeText(BDxhlbActivity.this, R.string.bdxhlbactivity_5, Toast.LENGTH_SHORT).show();
						return;
					}

					try {
						Intent intent = new Intent();
						if (moneyText.getText().toString() != null) {
							intent.putExtra("AllMoney", Integer.parseInt(allMoney + ""));
						} else {
							intent.putExtra("AllMoney", 0);
						}
						intent.putExtra("bs", bs);
						intent.putExtra("LotID", LOT_ID_BD);
						intent.putExtra("IssueID", issueID);
						intent.putExtra("IssueName", issueName);
						intent.putExtra("strBDWF", strBDWF);
						intent.putExtra("passType", passType);
						intent.putExtra("PlayTypeId", playTypeID);

						JSONObject params0 = new JSONObject();
						params0.put("playid", playTypeID);
						params0.put("number", getLotNum(ApplicationData.getInstance().getList_jcdto()));

						intent.putExtra("Number", "[" + params0.toString() + "]");
						intent.setClass(BDxhlbActivity.this, FaQiHeMaiActivity.class);
						BDxhlbActivity.this.startActivityForResult(intent, REQ_CODE_BUYMAIN);
					} catch (NumberFormatException e) {
						// TODO Auto-generated catch block
						// e.printStackTrace();
					} catch (JSONException e) {
						// TODO Auto-generated catch block
						// e.printStackTrace();
					}
				}
			}
		});
	}

	public void onResume() {
		super.onResume();
		
	}

	public void onPause() {
		super.onPause();
		
	}

	private TextWatcher textWatcher = new TextWatcher() {
		private boolean isChanged = false;

		public void afterTextChanged(Editable s) {
			// TODO Auto-generated method stub
			if (!et_beishu.getText().toString().equals("")) {
				if (isChanged) {
					return;
				}

				bs = Integer.parseInt(s.toString());
				isChanged = true;
				String str2 = s.toString().trim().replaceFirst("^0*", "");// 正则去除
				if (bs < 1) {
					Toast.makeText(BDxhlbActivity.this, R.string.bdxhlbactivity_9, Toast.LENGTH_SHORT).show();
					et_beishu.setText("1");
					bs = 1;
				} else if (bs > 99999) {
					Toast.makeText(BDxhlbActivity.this, R.string.bdxhlbactivity_10, Toast.LENGTH_SHORT).show();
					et_beishu.setText("99999");
					bs = 99999;
				} else {
					et_beishu.setText(str2);
				}
				et_beishu.setSelection(et_beishu.length());
				isChanged = false;
				et_beishu.invalidate();

				Long m = Long.parseLong(allMoney + "") * Integer.parseInt(et_beishu.getText().toString());
				moneyText.setText("共" + m + "元");
				// Log.e("bd", "bs= "+bs);

				// 保留小数点后2位
				BigDecimal bdbs = new BigDecimal(bs + "");
				String f1 = bdbs.multiply(bdminM).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString();
				String f2 = bdbs.multiply(bdmaxM).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString();
				// Log.e("bd", "f1= "+f1+" ,f2= "+f2);
				tvMyuce.setText(f1 + "元-" + f2 + "元");
			} else {
				et_beishu.setOnFocusChangeListener(new OnFocusChangeListener() {
					public void onFocusChange(View view, boolean hasFocus) {
						// TODO Auto-generated method stub
						if (hasFocus) {
							et_beishu.setText("");
						} else {
							if (et_beishu.getText().toString().equals("")) {
								Toast.makeText(BDxhlbActivity.this, R.string.bdxhlbactivity_11, Toast.LENGTH_SHORT)
										.show();
							}
						}
					}
				});
				bs = 0;
				moneyText.setText("共0元");
			}
		}

		@Override
		public void beforeTextChanged(CharSequence s, int start, int count, int after) {
			// TODO Auto-generated method stub
		}

		@Override
		public void onTextChanged(CharSequence s, int start, int before, int count) {
		}

	};

	class AsyncLoader extends AsyncTask<String, Integer, String> {// 继承AsyncTask

		String action;
		ShowTipDialog showdialog = new ShowTipDialog();

		// 1.准备运行
		protected void onPreExecute() {
			showdialog.showDialog(BDxhlbActivity.this);
		}

		// 2.正在后台运行
		@Override
		protected String doInBackground(String... paramsArr) {
			// 处理后台执行的任务，在后台线程执行
			String strResult = null;

			action = paramsArr[1];
			// 获取请求返回值
			String UserID = ApplicationData.getInstance().getUserID();
			strResult = GetRequestParams.getRequestUserIDResult(paramsArr[0], UserID, action, getApplicationContext());
			// 获取请求返回值
			return strResult;
		}

		// 3.进度更新
		protected void onProgressUpdate(Integer... progress) {
		}

		// 4.完成后台任务
		protected void onPostExecute(String result) {
			if (result != null) {
				if (action.equals("207")) {
					Buy(result);
				}
				showdialog.closeDialog();
			} else {
				Toast.makeText(BDxhlbActivity.this, getString(R.string.problem_01), Toast.LENGTH_LONG).show();
			}
		}

		// 5.完成后操作
		protected void onCancelled() {
		}

	}

	private void startBuyThread() {
		ArrayList<ChildDTO> arrayList = ApplicationData.getInstance().getList_jcdto();

		String lotNum = getLotNum(arrayList);

		AsyncLoader task = new AsyncLoader();
		dyn = new String[2];
		JSONObject params = new JSONObject();
		try {
			// 设置请求所需参数
			if (strBDWF.equals("RQSPF")) {
				playTypeID = 4501;
			} else if (strBDWF.equals("ZJQ")) {
				playTypeID = 4502;
			} else if (strBDWF.equals("SXDS")) {
				playTypeID = 4503;
			} else if (strBDWF.equals("BF")) {
				playTypeID = 4504;
			} else if (strBDWF.equals("BQC")) {
				playTypeID = 4505;
			}
			JSONObject params0 = new JSONObject();
			params0.put("playid", playTypeID);
			params0.put("number", lotNum);
			params.put("SchemeType", 1);// 方案类型 1自购，2合买，3保存 1
			params.put("BetType", 1);// 投注类型 1选号投注 2单式上传 3先发后传 1
			params.put("BonusScale", 0);
			params.put("AssureShare", 0);
			params.put("Description", "");
			params.put("OpenUserList", "");
			params.put("SecrecyLevel", 4);
			params.put("BuyShare", bs * allMoney);
			params.put("Multiple", bs);
			params.put("LotteryID", LotConstants.LOT_ID_BD);
			params.put("IssueID", issueID);
			params.put("IssueName", issueName);
			params.put("Number", "[" + params0.toString() + "]");
			params.put("Money", bs * allMoney);
		} catch (JSONException ex) {
			// TODO Auto-generated catch block
			Log.e("error", ex.toString());
		}
		dyn[0] = params.toString();
		dyn[1] = "207";
		task.execute(dyn);
	}

	public void Buy(String strResult) {
		try {
			JSONTokener jsonParser = new JSONTokener(strResult);
			JSONObject js = (JSONObject) jsonParser.nextValue();
			if (Integer.parseInt(js.getString("Code")) < 0) {
				buy_icon = R.drawable.buy_failure;
				if(js.getString("Data").contains(Constants.BALANCE_BUZU)){
					 Intent intent = new Intent();
					 intent.setClass(BDxhlbActivity.this, JddRechargeListActivity.class);
					 intent.putExtra("params", dyn[0]);
					 startActivityForResult(intent, DefConstants.REQ_CODE_NO_MONEY_2_RECHARGE);
				} else {
					new ShowTipDialog().showBuyInfo(BDxhlbActivity.this, js.getString("Data"), "购买失败", buy_icon, dyn[0]);
				}
			} else {
				buy_icon = R.drawable.buy_success;
				String msg = "发起北京单场第" + issueName + "期购买方案\n\n我的认购：" + (bs * allMoney/*
																					 * -
																					 * canDeductMoney
																					 */)/* + "元\n账户余额："
						+ ConvertJsonToList.getMap(js.getString("Data")).get("Balance").toString()/*
																								 * getBalance
																								 * (
																								 * )
																								 */+ "元"+"\n方案编号："+js.getString("Data").toString();
				new ShowTipDialog().showBuyInfo(BDxhlbActivity.this, msg, "投注成功", buy_icon, dyn[0]);

				// 存贮数据
				MyPreference.getInstance(this).storeBLotID(LOT_ID_BD);
			}
		} catch (JSONException ex) {
			// 异常处理代码
			Log.e("error", ex.toString());
		}
	}

	public String getBalance() {
		String money = "";
		String strResult = null;
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			// 设置请求所需参数
			JSONObject params = new JSONObject();
			// 设置请求action
			String action = "107";// 108获取用户基本信息
			// 获取请求返回值
			String UserID = ApplicationData.getInstance().getUserID();
			strResult = GetRequestParams.getRequestUserIDResult(params.toString(), UserID, action,
					getApplicationContext());
			JSONTokener jsonParser = new JSONTokener(strResult);
			JSONObject js = (JSONObject) jsonParser.nextValue();
			map = ConvertJsonToList.getMap(js.getString("Data"));
			money = map.get("Balance").toString();
		} catch (Exception ex) {
			// TODO Auto-generated catch block
			Log.e("error", ex.toString());
		}
		return money;
	}

	// 拼接投注号码
	public String getLotNum(List<ChildDTO> arrayList) {
		String lotNum = "";
		for (ChildDTO jcdto : arrayList) {
			lotNum += jcdto.getmId() + "=";

			if (strBDWF.equals("RQSPF")) {
				// i作为一场比赛中选胜平负的个数
				String info = "";
				String sp = JCUtil.zhuanHuanSPGeShi(jcdto.getStr_sp());
				if (sp.contains("3")) {
					info += "3/";
				}
				if (sp.contains("0")) {
					info += "0/";
				}
				if (sp.contains("1")) {
					info += "1/";
				}
				info = info.substring(0, info.length() - 1);
				lotNum = lotNum + info + ",";
			} else if (strBDWF.equals("SXDS")) {
				// i作为一场比赛中选胜平负的个数
				String info = "";
				String sp = JCUtil.zhuanHuanSPGeShi(jcdto.getStr_sp());
				if (sp.contains("3")) {// 3104分别代表上单 上双 下单 下双,对应购彩格式3210
					info += "3/";
				}
				if (sp.contains("1")) {
					info += "2/";
				}
				if (sp.contains("0")) {
					info += "1/";
				}
				if (sp.contains("4")) {
					info += "0/";
				}
				info = info.substring(0, info.length() - 1);
				lotNum = lotNum + info + ",";
			} else if (strBDWF.equals("BQC")) {
				String info = "";
				String touzhuNum = jcdto.getBtnBQCcontent();
				touzhuNum = touzhuNum.trim();// 截去最后的空格
				touzhuNum = touzhuNum.replaceAll("胜", "3");
				touzhuNum = touzhuNum.replaceAll("平", "1");
				touzhuNum = touzhuNum.replaceAll("负", "0");
				String[] sps = touzhuNum.split(" ");
				List<String> list = new ArrayList<String>();
				for (int i = 0; i < sps.length; i++) {
					if (!"".equals(sps[i])) {
						list.add(sps[i]);
					}
				}
				// list转化为string
				StringBuffer sb = new StringBuffer();
				for (int i = 0; i < list.size(); i++) {
					String s1 = list.get(i);
					String s2 = s1.substring(0, 1) + "-" + s1.substring(1, 2);
					sb.append(s2 + "/"); // ,
				}
				info = sb.toString();
				if (info.endsWith("/")) {
					info = info.substring(0, info.length() - 1);
				}
				lotNum = lotNum + info + ",";
			} else if (strBDWF.equals("ZJQ")) {
				String info = "";
				String touzhuNum = jcdto.getSelectZJQCG();
				info = touzhuNum.replaceAll(",", "/");
				info = info.replaceAll("7\\+", "7");
				if (info.endsWith("/")) {
					info = info.substring(0, info.length() - 1);
				}
				lotNum = lotNum + info + ",";
			} else if (strBDWF.equals("BF")) {
				String info = "";
				String touzhuNum = jcdto.getBtnbfAllcontent();
				touzhuNum = touzhuNum.replaceAll("胜其他", "9:0");
				touzhuNum = touzhuNum.replaceAll("平其他", "9:9");
				touzhuNum = touzhuNum.replaceAll("负其他", "0:9");
				info = touzhuNum.replaceAll(",", "/");
				if (info.endsWith("/")) {
					info = info.substring(0, info.length() - 1);
				}
				lotNum = lotNum + info + ",";
			}
		}
		lotNum = lotNum.substring(0, lotNum.length() - 1);
		if (passType.contains("单关")) {
			passType = passType.replaceAll("单关", "1*1");
		}
		lotNum = lotNum + "|" + passType + "|0";
		return lotNum;
	}

	/**
	 * 初始化奖金预测值
	 */
	public static void initMoney() {
		bdminM = new BigDecimal("0");
		bdmaxM = new BigDecimal("0");
	}

	// 获取金额
	public long getMoney(List<ChildDTO> arrayList) {
		// 当用户重新选择几串一时，初始化值
		bdminM = new BigDecimal("0");
		bdmaxM = new BigDecimal("0");
		count = 0;
		String[] types = passType.split(",");
		boolean isFirst = true;
		for (int i = 0; i < types.length; i++) {
			String type = types[i];
			// 进行计算所需的参数
			int num = getNumByPassType(type);
			if (num != 0) {
				Long time = System.currentTimeMillis();
				String result = "";
				if (strBDWF.equals("RQSPF") || (strBDWF.equals("SXDS"))) {
					result = JCUtil.getMatchCount(num, arrayList);
				} else {
					result = JczqBQCUtil.getMatchCount(num, arrayList);
				}
				time = System.currentTimeMillis() - time;
				count += Long.parseLong(result.split("\\|")[0]);
				// 最小奖金
				BigDecimal bdTWO = new BigDecimal("2");
				BigDecimal bd065 = new BigDecimal("0.65");
				BigDecimal bdmintemp = new BigDecimal(result.split("\\|")[1]);
				BigDecimal bdtemp = bdTWO.multiply(bd065).multiply(bdmintemp);
				if (isFirst) {
					BigDecimal bdmin0 = new BigDecimal(result.split("\\|")[1]);
					bdminM = bdTWO.multiply(bd065).multiply(bdmin0);
					isFirst = false;
				}
				if (bdtemp.compareTo(bdminM) == -1 || bdtemp.compareTo(bdminM) == 0) {
					bdminM = bdtemp;
				}
				// 最大奖金
				BigDecimal bdmax0 = new BigDecimal(result.split("\\|")[2]);
				bdmaxM = bdmaxM.add(bdTWO.multiply(bd065).multiply(bdmax0));
			}
		}

		moneyText.setText("共" + (Long.parseLong((count * 2) * bs + "") + "") + "元");
		// 保留小数点后2位,
		BigDecimal bdbs = new BigDecimal(bs + "");
		String f1 = bdbs.multiply(bdminM).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString();
		String f2 = bdbs.multiply(bdmaxM).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString();
		// Log.v("bd", "getMoney   f1= "+f1+" ,f2= "+f2);
		tvMyuce.setText(f1 + "元-" + f2 + "元");
		return count * 2;
	}

	// 根据过关方式获取计算阶乘时所需参数
	public int getNumByPassType(String type) {
		int num = 0;
		if (type.equals("单关")) {
			num = 1;
		}
		if (type.equals("2*1")) {
			num = 2;
		}
		if (type.equals("3*1")) {
			num = 3;
		}
		if (type.equals("4*1")) {
			num = 4;
		}
		if (type.equals("5*1")) {
			num = 5;
		}
		if (type.equals("6*1")) {
			num = 6;
		}
		if (type.equals("7*1")) {
			num = 7;
		}
		if (type.equals("8*1")) {
			num = 8;
		}
		if (type.equals("9*1")) {
			num = 9;
		}
		if (type.equals("10*1")) {
			num = 10;
		}
		if (type.equals("11*1")) {
			num = 11;
		}
		if (type.equals("12*1")) {
			num = 12;
		}
		if (type.equals("13*1")) {
			num = 13;
		}
		if (type.equals("14*1")) {
			num = 14;
		}
		if (type.equals("15*1")) {
			num = 15;
		}
		return num;
	}

	// 初始化
	public void initView() {
		initText();

		buy_jczqxhlb_linearlayout01 = findViewById(R.id.buy_jczqxhlb_linearlayout01);
		buy_jczqxhlb_linearlayout02 = findViewById(R.id.buy_jczqxhlb_linearlayout02);

		btnBuy = (TextView) findViewById(R.id.bottom_right_btn);
		btnChioce = (Button) findViewById(R.id.btn_playmethod);
		btnDelAll = findViewById(R.id.view_clear);
		buy_jcbasxhlb_btn_hemai = (TextView) findViewById(R.id.bottom_left_btn);

		et_beishu = (EditText) findViewById(R.id.et_beishu);
		et_beishu.addTextChangedListener(textWatcher);

		bs = 1;
		et_beishu.setText("1");
		moneyText.setText("共0元");

		// 标题
		titleBar();
	}

	// 初始化TextView
	public void initText() {
		moneyText = (TextView) findViewById(R.id.bottom_tv_money);
		tipText = (TextView) findViewById(R.id.tv_tips_endtime);
		tvMyuce = (TextView) findViewById(R.id.tv_win_ranger);
	}

	// 获取页面显示list
	private ArrayList<HashMap<String, Object>> getData(String jc_mid, String str_hteam, String str_vteam, String jc_sp,
			String str_time, String str_eq) {
		// 拿到新的号码放到List
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("buy_jcxhlb_list_mid", jc_mid);
		map.put("buy_jcxhlb_list_hteam", str_hteam);
		map.put("buy_jcxhlb_list_vteam", str_vteam);
		map.put("buy_jcxhlb_list_sp", jc_sp);
		map.put("buy_jcxhlb_list_delete", R.drawable.default_delbtn02);
		map.put("tip_time", str_time);
		map.put("buy_jcxhlb_list_vs", str_eq);
		list.add(map);
		return list;
	}

	/**
	 * 获取页面显示list,半全场，总进球，比分使用
	 * 
	 * @param jc_mid
	 * @param str_hteam
	 * @param str_vteam
	 * @param jc_sp
	 * @param selspslist
	 * @param str_time
	 * @return
	 */
	private ArrayList<HashMap<String, Object>> getBQCData(String jc_mid, String str_hteam, String str_vteam,
			String jc_sp, List<String> selspslist, String str_time) {
		// 拿到新的号码放到List
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("buy_jcxhlb_list_mid", jc_mid);
		map.put("buy_jcxhlb_list_hteam", str_hteam);
		map.put("buy_jcxhlb_list_vteam", str_vteam);
		map.put("buy_jcxhlb_list_touzhu", jc_sp);
		// list转化为string
		String str1;
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < selspslist.size(); i++) {
			if (!selspslist.get(i).equals("0")) {
				sb.append(selspslist.get(i) + ","); // ,
			}
		}
		str1 = sb.toString();
		map.put("buy_jcxhlb_list_sp", str1);
		map.put("buy_jcxhlb_list_delete", R.drawable.default_delbtn02);
		map.put("tip_time", str_time);
		list.add(map);
		return list;
	}

	// 初始化适配器
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public void initBaseAdapter(ArrayList list) {
		DelButtonAdapter listAdapter = null;
		DelButtonAdapterBDSXDS listAdapterBDSXDS = null;
		DelButtonAdapterBDZJQ listAdapterBQC = null;
		if (strBDWF.equals("RQSPF")) {
			listAdapter = new DelButtonAdapter(this, list, R.layout.buy_jcxhlb_list, new String[] {
					"buy_jcxhlb_list_mid", "buy_jcxhlb_list_hteam", "buy_jcxhlb_list_vteam", "buy_jcxhlb_list_sp",
					"buy_jcxhlb_list_delete", "buy_jcxhlb_list_vs" }, new int[] { R.id.buy_jcxhlb_list_hteam,
					R.id.buy_jcxhlb_list_vteam, R.id.buy_jcxhlb_list_s, R.id.buy_jcxhlb_list_p, R.id.buy_jcxhlb_list_f,
					R.id.buy_jcxhlb_list_delete, R.id.tv_item_vs });
			currLen = listAdapter.GetFootList().size();
			if (currLen != len) {
				bs = 1;
				passType = "";
				allMoney = 0;
				selected = new boolean[] { false, false, false, false, false, false, false, false, false, false, false,
						false, false, false, false };

				et_beishu.setText("1");
				moneyText.setText("共0元");
				tvMyuce.setText("0");
				btnChioce.setText("请选择过关方式");
			}
			if (currLen > 0) {
				list = new ArrayList<HashMap<String, Object>>();
				// 初始化全局JC变量
				ArrayList<ChildDTO> list_jcdto = new ArrayList<ChildDTO>();
				ApplicationData.getInstance().setList_jcdto(list_jcdto);

				for (ChildDTO jcdto : listAdapter.GetFootList()) {
					String jc_mid = jcdto.getmId();
					String str_team = jcdto.getStr_team();
					String str_hteam = jcdto.gethTeam();
					String str_vteam = jcdto.getvTeam();
					String str_sp = jcdto.getStr_sp();
					String str_eq = "VS";
					str_eq = jcdto.eQ;
					HashMap<String, Object> map = new HashMap<String, Object>();
					map.put("buy_jcxhlb_list_mid", jc_mid);
					map.put("buy_jcxhlb_list_team", str_team);
					map.put("buy_jcxhlb_list_hteam", str_hteam);
					map.put("buy_jcxhlb_list_vteam", str_vteam);
					map.put("buy_jcxhlb_list_sp", str_sp);
					map.put("buy_jcxhlb_list_delete", R.color.common_del);
					map.put("buy_jcxhlb_list_vs", str_eq);
					list.add(map);
					ApplicationData.getInstance().getList_jcdto().add(jcdto);
				}
			} else {
				buy_jczqxhlb_linearlayout01.setVisibility(View.GONE);
				buy_jczqxhlb_linearlayout02.setVisibility(View.VISIBLE);
			}
			List<ChildDTO> studentList = new ArrayList<ChildDTO>();
			studentList = ApplicationData.getInstance().getList_jcdto();
			tipText.setText("共" + studentList.size() + "场比赛，截止时间：" + studentList.get(0).geteTime());
			listView.setAdapter(listAdapter);
		} else if (strBDWF.equals("SXDS")) {
			listAdapterBDSXDS = new DelButtonAdapterBDSXDS(this, list, R.layout.buy_jcxhlb_list_bdsxds, new String[] {
					"buy_jcxhlb_list_mid", "buy_jcxhlb_list_hteam", "buy_jcxhlb_list_vteam", "buy_jcxhlb_list_sp",
					"buy_jcxhlb_list_delete" }, new int[] { R.id.buy_jcxhlb_list_hteam, R.id.buy_jcxhlb_list_vteam,
					R.id.buy_jcxhlb_list_s, R.id.buy_jcxhlb_list_p, R.id.buy_jcxhlb_list_f, R.id.buy_jcxhlb_list_xs,
					R.id.buy_jcxhlb_list_delete });
			currLen = listAdapterBDSXDS.GetFootList().size();
			if (currLen != len) {
				bs = 1;
				passType = "";
				allMoney = 0;
				selected = new boolean[] { false, false, false, false, false, false, false, false, false, false, false,
						false, false, false, false };

				et_beishu.setText("1");
				moneyText.setText("共0元");
				tvMyuce.setText("0");
				btnChioce.setText("请选择过关方式");
			}
			if (currLen > 0) {
				list = new ArrayList<HashMap<String, Object>>();
				// 初始化全局JC变量
				ArrayList<ChildDTO> list_jcdto = new ArrayList<ChildDTO>();
				ApplicationData.getInstance().setList_jcdto(list_jcdto);

				for (ChildDTO jcdto : listAdapterBDSXDS.GetFootList()) {
					String jc_mid = jcdto.getmId();
					String str_team = jcdto.getStr_team();
					String str_hteam = jcdto.gethTeam();
					String str_vteam = jcdto.getvTeam();
					String str_sp = jcdto.getStr_sp();
					HashMap<String, Object> map = new HashMap<String, Object>();
					map.put("buy_jcxhlb_list_mid", jc_mid);
					map.put("buy_jcxhlb_list_team", str_team);
					map.put("buy_jcxhlb_list_hteam", str_hteam);
					map.put("buy_jcxhlb_list_vteam", str_vteam);
					map.put("buy_jcxhlb_list_sp", str_sp);
					map.put("buy_jcxhlb_list_delete", R.color.common_del);
					list.add(map);
					ApplicationData.getInstance().getList_jcdto().add(jcdto);
				}
			} else {
				buy_jczqxhlb_linearlayout01.setVisibility(View.GONE);
				buy_jczqxhlb_linearlayout02.setVisibility(View.VISIBLE);
			}
			List<ChildDTO> studentList = new ArrayList<ChildDTO>();
			studentList = ApplicationData.getInstance().getList_jcdto();
			tipText.setText("共" + studentList.size() + "场比赛，截止时间：" + studentList.get(0).geteTime());
			listView.setAdapter(listAdapterBDSXDS);
		} else {// BQC BF ZJQ
			listAdapterBQC = new DelButtonAdapterBDZJQ(this, list, R.layout.buy_jczqbqcxhlb_list, new String[] {
					"buy_jcxhlb_list_mid", "buy_jcxhlb_list_hteam", "buy_jcxhlb_list_vteam", "buy_jcxhlb_list_touzhu",
					"buy_jcxhlb_list_delete", "buy_jcxhlb_list_sp" }, //
					new int[] { R.id.buy_jcxhlb_list_hteam, R.id.buy_jcxhlb_list_vteam, R.id.buy_jcxhlb_list_touzhu,
							R.id.buy_jcxhlb_list_delete }, strBDWF);

			currLen = listAdapterBQC.GetFootList().size();
			if (currLen != len) {
				bs = 1;
				passType = "";
				allMoney = 0;
				selected = new boolean[] { false, false, false, false, false, false, false, false, false, false, false,
						false, false, false, false };
				et_beishu.setText("1");
				moneyText.setText("共0元");
				tvMyuce.setText("0");
				btnChioce.setText("请选择过关方式");
			}
			if (currLen > 0) {
				list = new ArrayList<HashMap<String, Object>>();
				// 初始化全局JC变量
				ArrayList<ChildDTO> list_jcdto = new ArrayList<ChildDTO>();
				ApplicationData.getInstance().setList_jcdto(list_jcdto);

				for (ChildDTO jcdto : listAdapterBQC.GetFootList()) {
					String jc_mid = jcdto.getmId();
					String str_team = jcdto.getStr_team();
					String str_hteam = jcdto.gethTeam();
					String str_vteam = jcdto.getvTeam();
					// String str_sp = jcdto.getStr_sp();
					String str_touzhu = "";
					String str_sp = "";
					if (strBDWF.equals("BQC")) {
						str_touzhu = jcdto.getBtnBQCcontent();
						str_sp = jcdto.getBqc_selectsp();
					} else if (strBDWF.equals("ZJQ")) {
						str_touzhu = jcdto.getSelectZJQCG();
						str_sp = jcdto.getBqc_selectsp();
					} else if (strBDWF.equals("BF")) {
						str_touzhu = jcdto.getBtnbfAllcontent();
						str_sp = jcdto.getBqc_selectsp();
					}
					HashMap<String, Object> map = new HashMap<String, Object>();
					map.put("buy_jcxhlb_list_mid", jc_mid);
					map.put("buy_jcxhlb_list_team", str_team);
					map.put("buy_jcxhlb_list_hteam", str_hteam);
					map.put("buy_jcxhlb_list_vteam", str_vteam);
					map.put("buy_jcxhlb_list_touzhu", str_touzhu);
					map.put("buy_jcxhlb_list_sp", str_sp);// sp
					map.put("buy_jcxhlb_list_delete", R.color.common_del);
					list.add(map);
					ApplicationData.getInstance().getList_jcdto().add(jcdto);
				}
			} else {
				buy_jczqxhlb_linearlayout01.setVisibility(View.GONE);
				buy_jczqxhlb_linearlayout02.setVisibility(View.VISIBLE);
			}
			List<ChildDTO> studentList = new ArrayList<ChildDTO>();
			studentList = ApplicationData.getInstance().getList_jcdto();
			tipText.setText("共" + studentList.size() + "场比赛，截止时间：" + studentList.get(0).geteTime());
			listView.setAdapter(listAdapterBQC);
		}
	}

	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		if (resultCode == RESULT_OK) {
			if (requestCode == REQ_CODE_BUYMAIN || requestCode == REQ_CODE_NO_MONEY_2_RECHARGE) {
				ApplicationData.getInstance().resetJCData();
				setResult(110);
				finish();
			}
		}
	};

	// titleBar标题栏
	public void titleBar() {
		// Title信息(返回+Title)
		Button back = (Button) findViewById(R.id.top_title_back);
		back.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				if (currLen <= 0) {
					// 获得自定义的应用程序BallDTO,初始化
					ApplicationData.getInstance().resetJCData();
					initMoney();
					setResult(RESULT_CANCELED);
					BDxhlbActivity.this.finish();
				} else {
					MyDialog.Builder dialog = new MyDialog.Builder(BDxhlbActivity.this);
					dialog.setTitle("退出提示");
					dialog.setMessage("退出后您的投注将不会保存，确认继续?");
					dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int which) {
							// 获得自定义的应用程序BallDTO,初始化
							ApplicationData.getInstance().resetJCData();
							initMoney();
							setResult(RESULT_CANCELED);
							BDxhlbActivity.this.finish();
							dialog.cancel();
						}
					});
					dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int which) {
							dialog.cancel();
						}
					}).create().show();

				}
			}
		});

		TextView info = (TextView) findViewById(R.id.top_title_play_method);
		if (Activity.equals("BDActivity")) {
			if (strBDWF.equals("RQSPF")) {
				info.setText(R.string.buy_bd_spf);
			} else if (strBDWF.equals("SPF")) {
				info.setText(R.string.buy_bd_spf);
			} else if (strBDWF.equals("BQC")) {
				info.setText(R.string.buy_bd_bqc);
			} else if (strBDWF.equals("ZJQ")) {
				info.setText(R.string.buy_bd_zjq);
			} else if (strBDWF.equals("BF")) {
				info.setText(R.string.buy_bd_bf);
			} else if (strBDWF.equals("SXDS")) {
				info.setText(R.string.buy_bd_sxds);
			}
		} else if (Activity.equals("JcfootballActivity")) {
			if (strBDWF.equals("RQSPF")) {
				info.setText(R.string.buy_jc);
			} else if (strBDWF.equals("SPF")) {
				info.setText(R.string.buy_jczq_spf);
			} else if (strBDWF.equals("BQC")) {
				info.setText(R.string.buy_jczq_bqc);
			} else if (strBDWF.equals("ZJQ")) {
				info.setText(R.string.buy_jczq_zjq);
			} else if (strBDWF.equals("BF")) {
				info.setText(R.string.buy_jczq_bf);
			}

		}
	}

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			MyDialog.Builder dialog = new MyDialog.Builder(BDxhlbActivity.this);
			dialog.setTitle("退出提示");
			dialog.setMessage("退出后您的投注将不会保存，确认继续?");
			dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					// 获得自定义的应用程序BallDTO,初始化
					ApplicationData.getInstance().resetJCData();
					initMoney();
					setResult(RESULT_OK);
					BDxhlbActivity.this.finish();
					dialog.cancel();
				}
			});
			dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					dialog.cancel();
				}
			}).create().show();
		} else {
			return super.onKeyDown(keyCode, event);
		}
		return true;
	}

	@Override
	public void finish() {
		// TODO Auto-generated method stub
		super.finish();
	};
}
